package com.ruoyi.project.inspection.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.inspection.domain.ViProcessClass;
import com.ruoyi.project.inspection.service.IViProcessClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆检测进度条分类模板Controller
 *
 * @author ruoyi
 * @date 2020-07-17
 */
@RestController
@RequestMapping("/inspection/class")
public class ViProcessClassController extends BaseController {
    @Autowired
    private IViProcessClassService viProcessClassService;

    /**
     * 查询车辆检测进度条分类模板列表
     */
    @PreAuthorize("@ss.hasPermi('inspection:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(ViProcessClass viProcessClass) {
        startPage();
        List<ViProcessClass> list = viProcessClassService.selectViProcessClassList(viProcessClass);
        return getDataTable(list);
    }

    /**
     * 导出车辆检测进度条分类模板列表
     */
    @PreAuthorize("@ss.hasPermi('inspection:class:export')")
    @Log(title = "车辆检测进度条分类模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ViProcessClass viProcessClass) {
        List<ViProcessClass> list = viProcessClassService.selectViProcessClassList(viProcessClass);
        ExcelUtil<ViProcessClass> util = new ExcelUtil<ViProcessClass>(ViProcessClass.class);
        return util.exportExcel(list, "class");
    }

    /**
     * 获取车辆检测进度条分类模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('inspection:class:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(viProcessClassService.selectViProcessClassById(id));
    }

    /**
     * 新增车辆检测进度条分类模板
     */
    @PreAuthorize("@ss.hasPermi('inspection:class:add')")
    @Log(title = "车辆检测进度条分类模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViProcessClass viProcessClass) {
        return toAjax(viProcessClassService.insertViProcessClass(viProcessClass));
    }

    /**
     * 修改车辆检测进度条分类模板
     */
    @PreAuthorize("@ss.hasPermi('inspection:class:edit')")
    @Log(title = "车辆检测进度条分类模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViProcessClass viProcessClass) {
        return toAjax(viProcessClassService.updateViProcessClass(viProcessClass));
    }

    /**
     * 删除车辆检测进度条分类模板
     */
    @PreAuthorize("@ss.hasPermi('inspection:class:remove')")
    @Log(title = "车辆检测进度条分类模板", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(viProcessClassService.deleteViProcessClassByIds(ids));
    }
}
